package classobject;

public class Complex {
	private float real;
	private float img;

	public Complex() {
		this.real = 0;
		this.img = 0;
	}

	public Complex(float real, float img) {
		this.real = real;
		this.img = img;
	}

	Complex add(Complex b) {
		Complex c = new Complex(this.real + b.real, this.img + b.img);
		return c;
	}

	Complex subtract(Complex b) {
		Complex c = new Complex(this.real - b.real, this.img - b.img);
		return c;
	}

	void setNum(String str) {
		String[] a = str.split("");
		this.real = Float.parseFloat(a[0]);
		this.img = Float.parseFloat(a[1]);
	}

	void display() {
		System.out.println(this.real + "+" + this.img + "i");
	}
}
